<!--
 * @Author: wjj3
 * @Date: 2022-11-10 14:10:17
 * @Description: 查询导出EXCEL表格
-->
<template>
  <div class="list-container">
    <div class="search-container">
      <el-form ref="elForm" v-model="searchParams" size="medium" label-width="85px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="标题" class="titles">
              <el-input
                v-model="searchParams.title"
                placeholder="请输入标题"
                class="w100"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="起草部门：">
              <el-input
                v-model="searchParams.orgName"
                placeholder="请输入起草部门"
                class="w100"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="起草人：" class="drafter">
              <el-input
                v-model="searchParams.userName"
                placeholder="请输入起草人"
                class="w100"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="primary" size="small" @click="search">查询导出</el-button>
            <el-button class="cancel" type="primary" @click="resetFields" size="small">取消</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="文种名称：">
              <el-input
                v-model="searchParams.definitionName"
                placeholder="请输入文种名称"
                class="w100"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来文编号：">
              <el-input
                v-model="searchParams.receiveNumber"
                placeholder="请输入来文编号"
                class="w100"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="range" label="处理日期：">
              <el-date-picker
                v-model="searchParams.range"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="table-container">
      <jdf-table
        v-loading="loading"
        :columns="columns"
        :data="tableData"
        :table-attrs="tableAttrs"
        :pagination-attrs="paginationAttrs"
        :pagination-events="paginationEvents"
      ></jdf-table>
    </div>
  </div>
</template>

<script>
import { downloadFileByBlob } from 'jdf-util';
import QueryExport from '@/api/domains/QueryExport';
import listTableMixins from '@/mixins/listTableMixins';

export default {
  mixins: [listTableMixins],
  data() {
    return {
      functionName: 'query',
      service: QueryExport,
      columns: [],
    };
  },
  methods: {
    async search() {
      const sear = await QueryExport.query(this.searchParams);
      downloadFileByBlob(sear);
    }
  }
};
</script>
